package cn.itcast.hotel.controller;

import cn.itcast.hotel.pojo.PageResult;
import cn.itcast.hotel.pojo.RequestParams;
import cn.itcast.hotel.service.IHotelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @作者 itcast
 * @创建日期 2021/11/4 15:33
 **/
@RestController
@RequestMapping("hotel")
public class HotelController {
    @Autowired
    IHotelService hotelService;

    /**
     * list列表   添加商品信息
     * @param params
     * @return
     */
    @PostMapping("list")
    public PageResult list(@RequestBody RequestParams params){
        return hotelService.search(params);
    }

    /**
     * 条件过滤  添加商品信息过滤器
     * @param params
     * @return
     */
    @PostMapping("filters")
    public Map<String, List<String>> filters(@RequestBody RequestParams params){
        return hotelService.filters(params);
    }

    /**
     * 搜索建议
     * @param key
     * @return
     */
    @GetMapping("suggestion")
    public List<String> suggestion(@RequestParam("key") String key){
        return hotelService.suggestion(key);
    }
}
